package com.icehand.qiniu.enums;

import com.qiniu.common.Zone;
import lombok.Getter;

/**
 * @author icehand
 */
@Getter
public enum ZoneEnum {
    /**
     * 华东
     */
    HUA_DONG("huadong", Zone.zone0()),
    /**
     * 华北
     */
    HUA_BEI("huabei", Zone.zone1()),
    /**
     * 华南
     */
    HUA_NAN("huanan", Zone.zone2()),

    /**
     * 北美
     */
    NORTH_AMERICA("beimei", Zone.zoneNa0()),

    /**
     * 新加坡
     */
    SINGAPORE("xinjiapo", Zone.zoneAs0());

    private String name;
    private Zone zone;

    ZoneEnum(String name, Zone zone) {
        this.name = name;
        this.zone = zone;
    }

    public static Zone choiceZoneByName(String name) {
        for (ZoneEnum zoneEnum : ZoneEnum.values()) {
            if (zoneEnum.getName().equalsIgnoreCase(name)) {
                return zoneEnum.getZone();
            }
        }
        return Zone.autoZone();
    }
}
